import 'package:dali_ng_pera/manager/dnp_plugin_manager.dart';
import 'package:dali_ng_pera/net/dnp_net_config.dart';
import 'package:dali_ng_pera/page/splash/dnp_splash_widget.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'global/dnp_global_controller.dart';
import 'manager/dnp_cache_manager.dart';

void main() {
  DnpInit.initialize();
}

class DnpInit {

  static Future<void> initialize() async {

    WidgetsFlutterBinding.ensureInitialized();

    Get.put(DnpGlobalController());

    await _preInitialization();

    runApp(const MyApp());
  }

  static Future<void> _preInitialization() async {
    await DnpCacheManager();
    await DnpNetConfig().initialize();
  }
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: DnpSplashWidget(),
    );
  }
}
